// Copyright [2020] <unknown>
#include <bits/stdc++.h>
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

#define sz(x) ((int)x.size())

typedef long long LL;

LL bin(LL a, LL b, LL p) {
	LL res = 1;
	for (a%=p; b; b>>=1, a=a*a%p)
		if (b & 1)
			res = res * a % p;
	return res;
}

int n, m;
typedef long double LD;
const int N = 3e2+5;

LD dp[N][N];
int main(int argc, char const *argv[]) {
    int t;
    scanf("%d", &t);
    for (int kk=0; kk<t; ++kk) {
    	printf("Case #%d: ", kk+1);
    	memset(dp, 0, sizeof dp);
    	dp[0][0] = 1;
    	pair<int, int> p1, p2;
    	scanf("%d%d%d%d%d%d", &m, &n, &p1.first, &p1.second, &p2.first, &p2.second);
    	--p1.first;
    	--p1.second;
    	--p2.first;
    	--p2.second;
    	// dbg(n, m);
    	swap(p1.first, p1.second);
    	swap(p2.first, p2.second);
    	for (int i=0; i<n; ++i) {
    		for (int j=0; j<m; ++j) {
    			if (i==n-1 && j==m-1)
    				continue;
    			if (i >= p1.first && i <= p2.first && j >= p1.second && j <= p2.second) {
    				dp[i][j] = 0;
    				// dbg(i, j);
    				continue;
    			}
    			if (i+1<n)
    				dp[i+1][j] += dp[i][j] * 0.5;
    			else
    				dp[i][j+1] += dp[i][j] * 0.5;
    			if (j+1<m)
    				dp[i][j+1] += dp[i][j] * 0.5;
    			else
    				dp[i+1][j] += dp[i][j] * 0.5;
    		}
    	}
    	// dbg(dp[4][0]);
    	printf("%.5Lf\n", dp[n-1][m-1]);

    }
    return 0;
}